<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:a="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich"
    template="layout/template.xhtml">

<ui:define name="body">

    <h:form id="deviceActions" styleClass="edit">

        <rich:panel>
            <f:facet name="header">#{deviceActionsHome.managed ? 'Edit' : 'Add'} Device actions</f:facet>




            <s:decorate id="actionTypeField" template="layout/edit.xhtml">
                <ui:define name="label">Action type</ui:define>
                <h:inputText id="actionType"
                       required="true"
                           size="32"
                      maxlength="32"
                          value="#{deviceActionsHome.instance.actionType}">
                    <a:support event="onblur" reRender="actionTypeField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>


            <s:decorate id="nameField" template="layout/edit.xhtml">
                <ui:define name="label">Name</ui:define>
                <h:inputText id="name"
                       required="true"
                           size="100"
                      maxlength="100"
                          value="#{deviceActionsHome.instance.name}">
                    <a:support event="onblur" reRender="nameField" bypassUpdates="true" ajaxSingle="true"/>
                </h:inputText>
            </s:decorate>



            <div style="clear:both">
                <span class="required">*</span>
                required fields
            </div>

        </rich:panel>

        <div class="actionButtons">

            <h:commandButton id="save"
                          value="Save"
                         action="#{deviceActionsHome.persist}"
                       disabled="#{!deviceActionsHome.wired}"
                       rendered="#{!deviceActionsHome.managed}"/>

            <h:commandButton id="update"
                          value="Save"
                         action="#{deviceActionsHome.update}"
                       rendered="#{deviceActionsHome.managed}"/>

            <h:commandButton id="delete"
                          value="Delete"
                         action="#{deviceActionsHome.remove}"
                      immediate="true"
                       rendered="#{deviceActionsHome.managed}"/>

            <s:button id="cancelEdit"
                   value="Cancel"
             propagation="end"
                    view="/DeviceActions.xhtml"
                rendered="#{deviceActionsHome.managed}"/>

            <s:button id="cancelAdd"
                   value="Cancel"
             propagation="end"
                    view="/#{empty deviceActionsFrom ? 'DeviceActionsList' : deviceActionsFrom}.xhtml"
                rendered="#{!deviceActionsHome.managed}"/>

        </div>
    </h:form>

<rich:tabPanel switchType="ajax">

    <rich:tab label="Device *" labelClass="required">
    <div class="association" id="deviceParent">

        <h:outputText value="There is no device associated with this deviceActions."
                   rendered="#{deviceActionsHome.instance.device == null}"/>

        <rich:dataTable var="_device"
                   value="#{deviceActionsHome.instance.device}"
                rendered="#{deviceActionsHome.instance.device != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="deviceTable">
            <h:column>
                <f:facet name="header">Device id</f:facet>
                <h:outputText value="#{_device.deviceId}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Name</f:facet>
                <h:outputText value="#{_device.name}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Type</f:facet>
                <h:outputText value="#{_device.type}"/>
            </h:column>
        </rich:dataTable>

        <div class="actionButtons">
            <s:button id="#{deviceActionsHome.instance.device != null ? 'changeParent' : 'selectParent'}" value="#{deviceActionsHome.instance.device != null ? 'Change' : 'Select'} device"
                       view="/DeviceList.xhtml">
                <f:param name="from" value="DeviceActionsEdit"/>
            </s:button>
        </div>

    </div>
    </rich:tab>

    <rich:tab label="Action parameterses">
        <h:form styleClass="association" id="actionParametersesChildren">

            <h:outputText value="There are no actionParameterses associated with this deviceActions."
                       rendered="#{empty deviceActionsHome.actionParameterses}"/>

            <rich:dataTable value="#{deviceActionsHome.actionParameterses}"
                           var="_actionParameters"
                      rendered="#{not empty deviceActionsHome.actionParameterses}"
                    rowClasses="rvgRowOne,rvgRowTwo"
                            id="actionParametersesTable">
                <rich:column sortBy="#{_actionParameters.actionParametersId}">
                    <f:facet name="header">Action parameters id</f:facet>
                    <h:outputText value="#{_actionParameters.actionParametersId}"/>
                </rich:column>
                <rich:column sortBy="#{_actionParameters.parameterName}">
                    <f:facet name="header">Parameter name</f:facet>
                    <h:outputText value="#{_actionParameters.parameterName}"/>
                </rich:column>
                <rich:column sortBy="#{_actionParameters.parameterValue}">
                    <f:facet name="header">Parameter value</f:facet>
                    <h:outputText value="#{_actionParameters.parameterValue}"/>
                </rich:column>
            </rich:dataTable>

        </h:form>

        <f:subview rendered="#{deviceActionsHome.managed}" id="actionParameterses">
        <div class="actionButtons">
            <s:button id="addactionParameters"
                   value="Add actionParameters"
                    view="/ActionParametersEdit.xhtml"
             propagation="none">
                 <f:param name="deviceActionsDeviceActionsId"
                         value="#{deviceActionsHome.instance.deviceActionsId}"/>
                 <f:param name="actionParametersFrom" value="DeviceActions"/>
            </s:button>
        </div>
        </f:subview>
    </rich:tab>

    <rich:tab label="Status actions scripts">
        <h:form styleClass="association" id="statusActionsScriptsChildren">

            <h:outputText value="There are no statusActionsScripts associated with this deviceActions."
                       rendered="#{empty deviceActionsHome.statusActionsScripts}"/>

            <rich:dataTable value="#{deviceActionsHome.statusActionsScripts}"
                           var="_statusActionsScript"
                      rendered="#{not empty deviceActionsHome.statusActionsScripts}"
                    rowClasses="rvgRowOne,rvgRowTwo"
                            id="statusActionsScriptsTable">
                <rich:column sortBy="#{_statusActionsScript.statusActionsScriptId}">
                    <f:facet name="header">Status actions script id</f:facet>
                    <h:outputText value="#{_statusActionsScript.statusActionsScriptId}"/>
                </rich:column>
                <rich:column sortBy="#{_statusActionsScript.order}">
                    <f:facet name="header">Order</f:facet>
                    <h:outputText value="#{_statusActionsScript.order}"/>
                </rich:column>
            </rich:dataTable>

        </h:form>

        <f:subview rendered="#{deviceActionsHome.managed}" id="statusActionsScripts">
        <div class="actionButtons">
            <s:button id="addstatusActionsScript"
                   value="Add statusActionsScript"
                    view="/StatusActionsScriptEdit.xhtml"
             propagation="none">
                 <f:param name="deviceActionsDeviceActionsId"
                         value="#{deviceActionsHome.instance.deviceActionsId}"/>
                 <f:param name="statusActionsScriptFrom" value="DeviceActions"/>
            </s:button>
        </div>
        </f:subview>
    </rich:tab>
</rich:tabPanel>
</ui:define>

</ui:composition>
